
var Portfolio = new function () {
    this.Search = function (sortData) {
        var page = $("#portfolio-selectedpage").val();
        
        if ($("#portfolio-hidden-searchkeyword").val() != $('#portfolio-search-keyword').val()) {
            page = 0;
        }
        $('#portfolio-hidden-searchkeyword').val($('#portfolio-search-keyword').val());
        
        var requestData = {};
        requestData['pageIndex'] = page;
        requestData['keyword'] = $('#portfolio-search-keyword').val();
        // Build sorting data
        for (var sortKey in sortData) {
            requestData[sortKey] = sortData[sortKey];
        }
        $.ajax({
            url: "/Portfolio/Search",
            cache: false,
            data: requestData,
            dataType: "html",
            success: function (data) {
                var datas = data.split('||||||||');
                $("#portfolio-content").html(datas[0]);
                $("#portfolio-paging").html(datas[1]);
            }
        });
    };
};
